package file;
/**
 * 复制文件
 */

import java.io.*;
import java.io.FileOutputStream;

public class copy_file {
    public static void main(String[] agrs){
        File file=new File("e:\\JDK_API_1_6_zh_CN.CHM");
        File file1=new File("d:\\jdk8.exe");
        try {
            FileInputStream fis=new FileInputStream(file);//输入
            FileOutputStream fos=new FileOutputStream(file1);//输出
            BufferedInputStream bis=new BufferedInputStream(fis);
            BufferedOutputStream bos=new BufferedOutputStream(fos);
            byte[] tmp=new byte[1024];//建立一个数组
            int c=bis.read(tmp);
            //System.out.print(tmp);
            while (c!=-1){
                bos.write(tmp,0,c);//将字符写入数组的某一部分
                System.out.println("还剩"+bis.available()+"B");
                c=bis.read(tmp);
            }
            bis.close();bos.close();
        } catch (IOException e) {
            e.printStackTrace();
        }


    }
    }


